import JSEncrypt from 'jsencrypt';

const Encrypt = new JSEncrypt();

let publicKey =
  'MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDAIpI7ZPsdqlNNCJ5qZChqNis6tiKWdKv8J2G3pd/+GiKRKqFrTnyY7Ux4sk/G890ZcUeKzKkgAYiF2xoY+So0ZFaunvslszjn2B+XTLiZrIoF1KL2kVeHWoxsScyZndNbGf6RWiuon6bu9B9T1GdEkLNV4Z/MJ+xQ+UyI4cva2wIDAQAB';

let privateKey = `MIICeAIBADANBgkqhkiG9w0BAQEFAASCAmIwggJeAgEAAoGBAMAikjtk+x2qU00InmpkKGo2Kzq2IpZ0q/wnYbel3/4aIpEqoWtOfJjtTHiyT8bz3RlxR4rMqSABiIXbGhj5KjRkVq6e+yWzOOfYH5dMuJmsigXUovaRV4dajGxJzJmd01sZ/pFaK6ifpu70H1PUZ0SQs1Xhn8wn7FD5TIjhy9rbAgMBAAECgYEAv2exVgobQEpWAf/8EPEGcgjUuACKJGjGjMSOzG0q3/EZTpSxijz+UzrTW8oHP6PhN19qbhPEyGW+o9rJ/Ob76suwyk4GZnH/WBE0lwUYZukXMEObi1RbSJKswl4IQRW2ceZhUGjuzWqX0UxU8uBYiLSgdPtzt82V1Imiqpr1BkECQQDiZWZkuiz8rcu3ASlxbSz3p3OXYE0VQM9o2ozamSOb1iSbFxWdCz8uP8R3bEbS6VV0w08hKeK8F6kTaRnE2bXNAkEA2UJIs+YcOItCNXV59VU6MnYf06CFeU1n/ki8iptjkilZpCBUBGY+vqTCQ5V5JPThSWLka0q0TxMqVMen9mUrRwJBAKhbf6moSYweMkAFPSx8Y9RHUk5f7vK/H356CAUHnNNmjBJJOGlw06sxAIlOm9x8aHBMTav72gDGF5W3stIQlIECQQDS3u0l/4EAuNnIfX+kSda0x8ZYaANlG2aGfx7RAcWBRjVFgkNKCdt4uv37DweIgU5xJlVCdj3QSm/Z3ff+xW9dAkA65K2YINEsy5x/O+wLJLWPOYmoXD1paPK6mKGfGuNbWy0SJUeMw1wTb/nxIZaFQFPbgtFSp3Duy5IJXkwq5VDu`;

export default {
  /**
   * 加密
   * @param val 需加密参数
   * @returns 加密值
   */
  encrypt(val: string) {
    Encrypt.setPublicKey(publicKey);
    return Encrypt.encrypt(val);
  },

  /**
   * 解密
   * @param val 需解密参数
   * @returns 解密值
   */
  decrypt(val: string) {
    Encrypt.setPrivateKey(privateKey);
    return Encrypt.decrypt(val);
  },

  MD5KEY: 'e7c398ffcb2d4824b4d0a703e38eb0bb'
};
